#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() 
{
	int n;
	cin >> n;
	vector<int>x(n), y(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i]; //分别对x,y坐标进行排序
	}

	//找到最近的结点
	int X, Y, costX = 0, costY = 0;
	sort(x.begin(), x.end());
	for (int i = 0; i < n; i++) x[i] -= i;
	sort(x.begin(), x.end());
	X = x[n / 2];
	for (int i = 0; i < n; i++) costX += abs(x[i] - X);
	
	sort(y.begin(), y.end());
	Y = y[n / 2];
	for (int i = 0; i < n; i++) costY += abs(y[i] - Y);

	cout << costX + costY << endl;

	return 0;
}
